home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / amigaunits / scsidisk.pas < prev    next >
Pascal/Delphi Source File  |  2000-01-01  |  6KB  |  137 lines

  1. {
  2.     This file is part of the Free Pascal run time library.
  3.  
  4.     A file in Amiga system run time library.
  5.     Copyright (c) 1998-2000 by Nils Sjoholm
  6.     member of the Amiga RTL development team.
  7.  
  8.     See the file COPYING.FPC, included in this distribution,
  9.     for details about the copyright.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14.  
  15.  **********************************************************************}
  16.  
  17. {
  18.         SCSI exec-level device command
  19. }
  20.  
  21. unit scsidisk;
  22.  
  23. INTERFACE
  24.  
  25. uses exec;
  26.  
  27. {--------------------------------------------------------------------
  28.  *
  29.  *   SCSI Command
  30.  *      Several Amiga SCSI controller manufacturers are converging on
  31.  *      standard ways to talk to their controllers.  This include
  32.  *      file describes an exec-device command (e.g. for hddisk.device)
  33.  *      that can be used to issue SCSI commands
  34.  *
  35.  *   UNIT NUMBERS
  36.  *      Unit numbers to the OpenDevice call have encoded in them which
  37.  *      SCSI device is being referred to.  The three decimal digits of
  38.  *      the unit number refer to the SCSI Target ID (bus address) in
  39.  *      the 1's digit, the SCSI logical unit (LUN) in the 10's digit,
  40.  *      and the controller board in the 100's digit.
  41.  *
  42.  *      Examples:
  43.  *                0     drive at address 0
  44.  *               12     LUN 1 on multiple drive controller at address 2
  45.  *              104     second controller board, address 4
  46.  *               88     not valid: both logical units and addresses
  47.  *                      range from 0..7.
  48.  *
  49.  *   CAVEATS
  50.  *      Original 2090 code did not support this command.
  51.  *
  52.  *      Commodore 2090/2090A unit numbers are different.  The SCSI
  53.  *      logical unit is the 100's digit, and the SCSI Target ID
  54.  *      is a permuted 1's digit: Target ID 0..6 maps to unit 3..9
  55.  *      (7 is reserved for the controller).
  56.  *
  57.  *          Examples:
  58.  *                3     drive at address 0
  59.  *              109     drive at address 6, logical unit 1
  60.  *                1     not valid: this is not a SCSI unit.  Perhaps
  61.  *                      it's an ST506 unit.
  62.  *
  63.  *      Some controller boards generate a unique name (e.g. 2090A's
  64.  *      iddisk.device) for the second controller board, instead of
  65.  *      implementing the 100's digit.
  66.  *
  67.  *      There are optional restrictions on the alignment, bus
  68.  *      accessability, and size of the data for the data phase.
  69.  *      Be conservative to work with all manufacturer's controllers.
  70.  *
  71.  *------------------------------------------------------------------}
  72.  
  73. Const
  74.  
  75.     HD_SCSICMD          = 28;   { issue a SCSI command to the unit }
  76.                                 { io_Data points to a SCSICmd }
  77.                                 { io_Length is sizeof(struct SCSICmd) }
  78.                                 { io_Actual and io_Offset are not used }
  79.  
  80. Type
  81.  
  82.     pSCSICmd = ^tSCSICmd;
  83.     tSCSICmd = record
  84.         scsi_Data       : Pointer; { word aligned data for SCSI Data Phase }
  85.                                    { (optional) data need not be byte aligned }
  86.                                    { (optional) data need not be bus accessable }
  87.         scsi_Length     : ULONG;   { even length of Data area }
  88.                                    { (optional) data can have odd length }
  89.                                    { (optional) data length can be > 2**24 }
  90.         scsi_Actual     : ULONG;   { actual Data used }
  91.         scsi_Command    : Pointer; { SCSI Command (same options as scsi_Data) }
  92.         scsi_CmdLength  : Word;    { length of Command }
  93.         scsi_CmdActual  : Word;    { actual Command used }
  94.         scsi_Flags      : Byte;    { includes intended data direction }
  95.         scsi_Status     : Byte;    { SCSI status of command }
  96.         scsi_SenseData  : STRPTR;  { sense data: filled IF SCSIF_[OLD]AUTOSENSE }
  97.                                    { is set AND scsi_Status has CHECK CONDITION }
  98.                                    { (bit 1) set }
  99.         scsi_SenseLength : Word;   { size of scsi_SenseData, also bytes to }
  100.                                    { request w/ SCSIF_AUTOSENSE, must be 4..255 }
  101.         scsi_SenseActual : Word;   { amount actually fetched (0 means no sense) }
  102.     end;
  103.  
  104.  
  105. Const
  106.  
  107. {----- scsi_Flags -----}
  108.     SCSIF_WRITE         = 0;    { intended data direction is out }
  109.     SCSIF_READ          = 1;    { intended data direction is in }
  110.     SCSIB_READ_WRITE    = 0;    { (the bit to test) }
  111.  
  112.     SCSIF_NOSENSE       = 0;       { no automatic request sense }
  113.     SCSIF_AUTOSENSE     = 2;       { do standard extended request sense }
  114.                                          { on check condition }
  115.     SCSIF_OLDAUTOSENSE  = 6;       { do 4 byte non-extended request }
  116.                                         { sense on check condition }
  117.     SCSIB_AUTOSENSE     = 1;       { (the bit to test) }
  118.     SCSIB_OLDAUTOSENSE  = 2;       { (the bit to test) }
  119.  
  120.  
  121. {----- SCSI io_Error values -----}
  122.     HFERR_SelfUnit      = 40;   { cannot issue SCSI command to self }
  123.     HFERR_DMA           = 41;   { DMA error }
  124.     HFERR_Phase         = 42;   { illegal or unexpected SCSI phase }
  125.     HFERR_Parity        = 43;   { SCSI parity error }
  126.     HFERR_SelTimeout    = 44;   { Select timed out }
  127.     HFERR_BadStatus     = 45;   { status and/or sense error }
  128.  
  129. {----- OpenDevice io_Error values -----}
  130.     HFERR_NoBoard       = 50;   { Open failed for non-existant board }
  131.  
  132. IMPLEMENTATION
  133.  
  134. end.
  135.  
  136.  
  137.